/*
package org.itboys.mobile.controller.weixin;

import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.admin.entity.lasted.SystemDictionary;
import org.itboys.admin.service.lasted.SystemDictionaryService;
import org.itboys.commons.CommonConstants;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mobile.common.SundayCommonConstants;
import org.itboys.mobile.dto.SundayMemberSessionDto;
import org.itboys.mobile.dto.wallet.SundayAccountDto;
import org.itboys.mobile.dto.wallet.SundayWalletDto;
import org.itboys.mobile.dto.wallet.SundayWalletRecordDto;
import org.itboys.mobile.entity.mysql.wallet.SundayWallet;
import org.itboys.mobile.service.mongo.front.SundayFrontAccountService;
import org.itboys.mobile.service.mysql.front.SundayFrontWalletRecordService;
import org.itboys.mobile.service.mysql.front.SundayFrontWalletService;
import org.itboys.mobile.util.AccountIdHoldUtils;
import org.itboys.mobile.util.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;


*/
/**
 * Created by zhangyang on 2017/12/19.
 * 圣代_钱包_controller_weixin
 *//*

@Controller
@RequestMapping("/sunday/weixin/wallet")
public class SundayWeiXinWalletControllerOld extends BaseController{

    @Autowired
    private SundayFrontWalletService walletService;
    @Autowired
    private SundayFrontAccountService cashAccountService;
    @Autowired
    private SundayFrontWalletRecordService walletRecordService;
    @Autowired
    private SystemDictionaryService systemDictionaryService;


    */
/**
     * 钱包主页
     * @param request
     * @param
     *//*

    @RequestMapping(value="/index", method=RequestMethod.GET)
    public String index(HttpServletRequest request,Model model){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            SundayWalletDto walletDto = walletService.getSingleWalletDto(memberId,true,false,null);
            model.addAttribute("wallet",walletDto);
            return "/aigou/weixin/wallet/index";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/index----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    */
/**
     * 账户余额/积分/爱购币记录页面
     * @param request
     * @param response
     * @param flag 标识类型:1-余额,2-积分,3-爱购币,4-提成
     * @return
     *//*

    @RequestMapping(value="/record", method=RequestMethod.GET)
    public String record(HttpServletRequest request,
                        HttpServletResponse response,Model model,
                        @RequestParam(value = "flag",required = true) Integer flag,
                        @RequestParam(value = "memberId",required = true) Long memberId){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            SundayWalletDto walletDto = walletService.getSingleWalletDto(memberId,false,true,flag);
            model.addAttribute("wallet",walletDto);
            model.addAttribute("flag",flag);
            return "/aigou/weixin/wallet/record";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/record----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    */
/**
     * 获取账户余额/积分/爱购币记录
     * @param flag 1-余额,2-积分,3-爱购币
     *//*

    @RequestMapping(value="/select", method= RequestMethod.GET)
    @ApiOperation("【微信端】获取账户余额/积分/爱购币/提成记录")
    public String select(
            HttpServletRequest request,Model model,
            @ApiParam(required = false, name = "flag", value = "1-账户余额,2-积分,3-爱购币,4-提成") @RequestParam(value = "flag",required = false) Integer flag){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            List<SundayWalletRecordDto> recordList = walletRecordService.getRecord(memberId, flag,null,request);
            model.addAttribute("recordList",recordList);
            return "/aigou/weixin/wallet/record_data";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/select----e="+e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    */
/**
     * 余额充值页面
     * @param request
     * @param response
     * @param
     *//*

    @RequestMapping(value="/recharge", method=RequestMethod.GET)
    public String recharge(HttpServletRequest request,
                            HttpServletResponse response,Model model){
        try{
            AccountIdHoldUtils.getSessionMember(request);
            return "/aigou/weixin/wallet/recharge";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/recharge----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    */
/**
     * 查询用户所属钱包
     * (测试接口,上线后删除)
     * @param request
     * @param response
     *//*

    @RequestMapping(value="/getByMemberId", method= RequestMethod.GET)
    @ApiOperation(value="查询用户所属钱包")
    public void getByMemberId(HttpServletRequest request,HttpServletResponse response){
        try {
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            SundayWallet wallet = walletService.getByMemberId(memberId);
            ResponseMessage.success(wallet);
        } catch (Exception e) {

            String msg ="";
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
            }else{
                msg= CommonConstants.ERROMSG;
                logger.info("/sunday/weixin/wallet/getByMemberId--------"+e);
            }
            e.printStackTrace();
            ResponseMessage.error(CommonConstants.FAIL_CODE,msg);
        }
    }

    */
/**
     * 变更钱包
     * (测试接口,上线后删除)
     * @param request
     * @param response
     * @param type  变更的类型:
     *              账户余额(1-充值,2-提成,3-购物使用,4-提现),
     *              积分(5-积分兑换,6-购物获得,7-登录获得,8-评论获得,9-分享获得),
     *              爱购币(10-抵扣,12-购物获得,12-分享商品获得,13-展示到社区获得,14-评论获得)
     * @param amount    变更的金额/分数/爱购币数量
     * @param orderNo   订单号
     *//*

    @RequestMapping(value="/changeWallet", method= RequestMethod.POST)
    @ApiOperation(value="变更钱包")
    public void changeWallet(HttpServletRequest request,
                             HttpServletResponse response,
                             @ApiParam(required=true, name="type", value="变更的类型:账户余额(1-充值,2-提成,3-购物使用,4-提现),积分(5-积分兑换,6-购物获得,7-登录获得,8-评论获得,9-分享获得),爱购币(10-抵扣,11-购物获得,12-分享商品获得,13-展示到社区获得,14-评论获得)")@RequestParam(value = "type", required = true)Integer type,
                             @ApiParam(required=true, name="amount", value="变更的金额/分数/爱购币数量")@RequestParam(value = "amount", required = true)BigDecimal amount,
                             @ApiParam(required=false, name="orderNo", value="订单号")@RequestParam(value = "orderNo", required = false)String orderNo){
        try {
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            walletService.changeWallet(memberId,type,amount,orderNo,"",null);
            ResponseMessage.success();
        } catch (Exception e) {

            String msg ="";
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
            }else{
                msg= CommonConstants.ERROMSG;
                logger.info("/sunday/weixin/wallet/changeWallet--------"+e);
            }
            e.printStackTrace();
            ResponseMessage.error(CommonConstants.FAIL_CODE,msg);
        }
    }

    */
/**
     * 提现账户主页
     * @param request
     * @param response
     * @param
     *//*

    @RequestMapping(value="/account/index", method=RequestMethod.GET)
    public String accountIndex(HttpServletRequest request,
                        HttpServletResponse response,Model model){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            List<SundayAccountDto> accounts = cashAccountService.select(memberId);
            model.addAttribute("accounts",accounts);
            return "/aigou/weixin/wallet/account/index";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/account/index----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    */
/**
     * 新增提现账户页面
     * @param request
     * @param response
     * @param
     *//*

    @RequestMapping(value="/account/add", method=RequestMethod.GET)
    public String accountAdd(
            HttpServletRequest request,
            Model model,@RequestParam(value = "id", required = true)Long id){
        try{
            SundayMemberSessionDto member = AccountIdHoldUtils.getSessionMember(request);
            SundayAccountDto account = cashAccountService.getSingleAccountDto(id);
            //获取维护的银行
            List<SystemDictionary> bankList = systemDictionaryService.getDictionaryByKey("bank");
            model.addAttribute("bankList",bankList);
            model.addAttribute("account",account);
            return "/aigou/weixin/wallet/account/add";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/account/add----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    @RequestMapping(value="/account/save", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】保存提现账户")
    public void saveAccount(
            HttpServletRequest request,
            HttpServletResponse response,
            @ApiParam(required=true, name="id", value="id。新增时传入0")@RequestParam(value = "id", required = true)Long id,
            @ApiParam(required=true, name="type", value="类别:1-银行卡,2-支付宝,3-微信")@RequestParam(value = "type", required = true)int type,
            @ApiParam(required=true, name="realName", value="真实姓名")@RequestParam(value = "realName", required = true)String realName,
            @ApiParam(required=true, name="phone", value="手机号码")@RequestParam(value = "phone", required = true)String phone,
            @ApiParam(required=false, name="bankName", value="银行")@RequestParam(value = "bankName", required = false)String bankName,
            @ApiParam(required=false, name="logo", value="logo")@RequestParam(value = "logo", required = false)String logo,
            @ApiParam(required=false, name="openingBank", value="开户行")@RequestParam(value = "openingBank", required = false)String openingBank,
            @ApiParam(required=true, name="account", value="账户")@RequestParam(value = "account", required = true)String account){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            cashAccountService.saveAccount(id,memberId,type,realName,phone,bankName,logo,openingBank,account);
            ResponseMessage.success();
        }catch (Exception e){
            String msg = CommonConstants.ERROMSG;
            Integer code= CommonConstants.FAIL_CODE;
            //自定义异常（签名错误）
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
                //token已过期
            }else  if(e.getClass().getSimpleName().equalsIgnoreCase("TokenException")){
                code= CommonConstants.TOKEN_CODE;
                msg= CommonConstants.TOKENMSG;
            }else{
                logger.error("/sunday/weixin/wallet/account/save----e="+e.getMessage());
            }
            e.printStackTrace();
            ResponseMessage.error(code,msg);
        }
    }

    @RequestMapping(value="/account/delete", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】删除提现账户")
    public void deleteAccount(
            HttpServletRequest request,
            @ApiParam(required=true, name="id", value="提现账户id")@RequestParam(value = "id", required = true)Long id){
        try {
            AccountIdHoldUtils.getSessionMember(request);
            cashAccountService.delete(id);
            ResponseMessage.success();
        } catch (Exception e) {
            String msg ="";
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErroException")){
                msg=e.getMessage();
            }else{
                msg= CommonConstants.ERROMSG;
                logger.info("/sunday/weixin/wallet/account/delete--------"+e);
            }
            e.printStackTrace();
            ResponseMessage.error(CommonConstants.FAIL_CODE,msg);
        }
    }

    */
/**
     * 提现记录页面
     * @param request
     * @param response
     * @param
     *//*

    @RequestMapping(value="/cash/record", method=RequestMethod.GET)
    public String cashRecord(HttpServletRequest request,
                              HttpServletResponse response,Model model){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();

            List<SundayWalletRecordDto> list = walletRecordService.getRecord(memberId, null,SundayCommonConstants.wallet_record_type_amount_cash,request);;
            model.addAttribute("list",list);
            return "/aigou/weixin/wallet/cash/record";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/cash/record----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    @RequestMapping(value="/cash/select", method=RequestMethod.GET)
    public String cashSelect(HttpServletRequest request,
                             HttpServletResponse response,Model model){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();

            List<SundayWalletRecordDto> list = walletRecordService.getRecord(memberId, null,SundayCommonConstants.wallet_record_type_amount_cash,request);;
            model.addAttribute("list",list);
            return "/aigou/weixin/wallet/cash/data";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/cash/record----e="+e.getMessage());
            e.printStackTrace();
            return null;
        }
    }

    */
/**
     * 申请提现页面
     * @param request
     * @param response
     * @param
     *//*

    @RequestMapping(value="/cash/apply", method=RequestMethod.GET)
    public String cashApply(HttpServletRequest request,
                        HttpServletResponse response,Model model){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            //获取提现账户
            List<SundayAccountDto> accounts = cashAccountService.select(memberId);
            SundayWallet wallet = walletService.getByMemberId(memberId);
            model.addAttribute("accounts",accounts);
            //可提现金额
            model.addAttribute("canMoney",wallet.getTotalAmount());
            return "/aigou/weixin/wallet/cash/apply";
        }catch (Exception e){
            logger.error("/sunday/weixin/wallet/cash/apply----e="+e.getMessage());
            e.printStackTrace();
            return "/aigou/weixin/error";
        }
    }

    @RequestMapping(value="/cash/save", method= RequestMethod.POST)
    @ApiOperation(value="【微信端】保存提现记录")
    public void saveApplyCash(HttpServletRequest request,
                           HttpServletResponse response,
                           @ApiParam(required=true, name="accountId", value="提现账户id")@RequestParam(value = "accountId", required = true)Long accountId,
                           @ApiParam(required=true, name="money", value="提现金额")@RequestParam(value = "money", required = true)BigDecimal money){
        try{
            Long memberId = AccountIdHoldUtils.getSessionMember(request).getId();
            walletService.saveCash(accountId,money,memberId);
            ResponseMessage.success();
        }catch (Exception e){
            String msg = CommonConstants.ERROMSG;
            Integer code= CommonConstants.FAIL_CODE;
            //自定义异常（签名错误）
            if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
                msg=e.getMessage();
                //token已过期
            }else  if(e.getClass().getSimpleName().equalsIgnoreCase("TokenException")){
                code= CommonConstants.TOKEN_CODE;
                msg= CommonConstants.TOKENMSG;
            }else{
                logger.error("/sunday/weixin/wallet/cash/save----e="+e.getMessage());
            }
            e.printStackTrace();
            ResponseMessage.error(code,msg);
        }
    }
}
*/
